<template>
	<view>
		<view class="uni-column" style="margin-top: 25px;width: 90%;margin-left: 5%; ">
			<input class="uni-input input" v-model="phone" type="number" placeholder="请输入手机号" />
			<input class="uni-input input" v-model="password"   placeholder="请输入密码" />
		</view>
		<view class="uni-column" style="padding-top: 20px; padding-bottom: 60px;width: 90%;margin-left: 5%;">
			<button class="loginbtn" @click="addstaff()">添加工作人员</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				phone:'',
				password:'',
				httpurl: getApp().globalData.weburl,
			}
		},
		methods: {
			addstaff(){
				var that = this;
				uni.request({
					url: that.httpurl+'addstaff', //服务器地址+接口名
					data: {
						phone:this.phone,
						password:this.password
					},
					method: 'POST',
					header: {
					  'X-Requested-With': 'XMLHttpRequest',
					  "Accept": "application/json",
					  "Content-Type": "application/json; charset=UTF-8"
					 },
					dataType: 'json',
				 success: (res) => {
					 console.log("request success");
					 console.log(res.data);
					 uni.showToast({
					 	title: "添加成功",
					 	icon: 'none'
					 })
					 uni.navigateBack();
				 },
				 fail:(res) =>{
					 console.log("request fail");
					 }
				 })
			}
		}
	}
</script>

<style>
.loginbtn{
	color: white;
	background-color: #528FFF;
	border-radius: 10px;
}
</style>
